#pragma once

#include <vector>
#include <fstream>
#include "afxwin.h"
#include "afxcmn.h"
#include "asio_declare.h"

class TPMKVMap;

class TClientDlg : public CDialog
{
	DECLARE_DYNAMIC(TClientDlg)
public:
	TClientDlg(const std::string &hostip, const std::string &port, CWnd* pParent = NULL);
	virtual ~TClientDlg();
	enum { IDD = IDD_DLG_CLIENT };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);
	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnInitDialog();
public:
	afx_msg void OnBnClickedBtnSend();
	afx_msg void OnBnClickedBtnOlList();
	afx_msg void OnItemchangedLstUser(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnBnClickedBtnSendFile();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL DestroyWindow();
	virtual void OnCancel();
	void AppendMsg2Wnd(const CString &str);
	void SetKVMapPtr(TPMKVMap *p){m_pKVMap = p;}
	void InsertItemToBack(const DWORD &ip);
	void RemoveItem(const DWORD &ip);
	void MsgOfSendFile(const CString &sName, const size_t flen, const CString &host, const CString &port, IPLst &lst);
public:
	CRichEditCtrl *m_pRichMsg;
	CRichEditCtrl *m_pRichSend;
	CListCtrl m_lstUsers;
	CFont m_iplst_font;
	CFont m_msg_font;
	TPMKVMap *m_pKVMap;
	DWORD m_ip;
	std::string m_shostIp;
	std::string m_sport;
	IPLst m_sendIpLst;
	std::map<CString, size_t> m_acceptFiles;
	afx_msg void OnBnClickedBtnCloseService();
};
